/* This file must be used with compiler version 7.3.8.6 */

#ifdef __VERSIONNUM__
#if __VERSIONNUM__ != 0x07030806
#error The compiler version does not match the version of the sysreg.h include
#endif
#endif

/*************************************************************************
 *
 * sysreg.h
 *
 * (c) Copyright 1996-2004 Analog Devices, Inc.  All rights reserved.
 *
 ************************************************************************/

/*
 *  Identifiers for __builtin_sysreg_readn and __builtin_sysreg_writen.
 *    Use of other values will produce unpredictable results.
 *
 *  size [1|2|4] gives the size of the register in machine words
 *  pairable     this (and the next) register can be accessed with the '2'
 *               version
 *  quadable     this (and the next 3) registers can be accessed with the '4'
 *               version
 *
 *  Example:
 *
 *    int x;
 *      ...
 *    x = __builtin_sysreg_read(__SYSCON);
 *      ...
 *    __builtin_sysreg_write(__SYSCON, x);
 *
 *  NB: The compiler does not do any checking to ensure that you are accessing
 *      a register with the correct function. Also note that not all registers
 *      listed in the file may be valid for the specified architecture, for
 *      example INTCTL is valid for a ADSP-TS20x target but is not valid for
 *      the ADSP-TS101.
 *
 */

#ifndef __SYSREG_DEFINED
#define __SYSREG_DEFINED

#ifdef __NOUNDERSCORES__
  #define __UNDER__(X) X
#else
  #define __UNDER__(X) __##X
#endif

enum __sysregs {

/* quad sized registers */

  __UNDER__(DCS0)                 = 276,   /* size 4 */
  __UNDER__(DCS1)                 = 277,   /* size 4 */
  __UNDER__(DCS2)                 = 278,   /* size 4 */
  __UNDER__(DCS3)                 = 279,   /* size 4 */
  __UNDER__(DC4)                  = 280,   /* size 4 */
  __UNDER__(DC5)                  = 281,   /* size 4 */
  __UNDER__(DC6)                  = 282,   /* size 4 */
  __UNDER__(DC7)                  = 283,   /* size 4 */
  __UNDER__(DC8)                  = 284,   /* size 4 */
  __UNDER__(DC9)                  = 285,   /* size 4 */
  __UNDER__(DC10)                 = 286,   /* size 4 */
  __UNDER__(DC11)                 = 287,   /* size 4 */
  __UNDER__(DC12)                 = 288,   /* size 4 */
  __UNDER__(DC13)                 = 289,   /* size 4 */
  __UNDER__(DCD0)                 = 290,   /* size 4 */
  __UNDER__(DCD1)                 = 291,   /* size 4 */
  __UNDER__(DCD2)                 = 292,   /* size 4 */
  __UNDER__(DCD3)                 = 293,   /* size 4 */
  __UNDER__(DCNT)                 = 294,   /* size 4 */
  __UNDER__(DCNTST)               = 295,   /* size 4 */
  __UNDER__(DCNTCL)               = 296,   /* size 4 */
  __UNDER__(LBUFTX0)              = 311,   /* size 4 */
  __UNDER__(LBUFRX0)              = 315,   /* size 4 */
  __UNDER__(LBUFTX1)              = 312,   /* size 4 */
  __UNDER__(LBUFRX1)              = 316,   /* size 4 */
  __UNDER__(LBUFTX2)              = 313,   /* size 4 */
  __UNDER__(LBUFRX2)              = 317,   /* size 4 */
  __UNDER__(LBUFTX3)              = 314,   /* size 4 */
  __UNDER__(LBUFRX3)              = 318,   /* size 4 */

/* pair sized registers */

  __UNDER__(DSTAT)                = 297,   /* size 2 */
  __UNDER__(DSTATC)               = 298,   /* size 2 */

/* single registers */

  __UNDER__(SYSCON)               = 299,   /* size 1 */
  __UNDER__(SYSTATCL)             = 300,   /* size 1 */
  __UNDER__(SDRCON)               = 301,   /* size 1 */
  __UNDER__(SYSTAT)               = 302,   /* size 1 */
  __UNDER__(BMAX)                 = 305,   /* size 1 */
  __UNDER__(BMAXC)                = 306,   /* size 1 */
  __UNDER__(CCNT0)                = 274,   /* size 1 */
  __UNDER__(CCNT1)                = 275,   /* size 1 */
  __UNDER__(SQCTL)                = 355,   /* size 1 */
  __UNDER__(SQCTLST)              = 356,   /* size 1 */
  __UNDER__(SQCTLCL)              = 357,   /* size 1 */
  __UNDER__(SQSTAT)               = 358,   /* size 1 */
  __UNDER__(BUSLK)                = 307,   /* size 1 */
  __UNDER__(LCTL0)                = 319,   /* size 1 */
  __UNDER__(LCTL1)                = 320,   /* size 1 */
  __UNDER__(LCTL2)                = 321,   /* size 1 */
  __UNDER__(LCTL3)                = 322,   /* size 1 */
  __UNDER__(LSTAT0)               = 323,   /* size 1 */
  __UNDER__(LSTAT1)               = 324,   /* size 1 */
  __UNDER__(LSTAT2)               = 325,   /* size 1 */
  __UNDER__(LSTAT3)               = 326,   /* size 1 */
  __UNDER__(LSTATC0)              = 327,   /* size 1 */
  __UNDER__(LSTATC1)              = 328,   /* size 1 */
  __UNDER__(LSTATC2)              = 329,   /* size 1 */
  __UNDER__(LSTATC3)              = 330,   /* size 1 */
  __UNDER__(LTCTL0)               = 331,   /* size 1 */
  __UNDER__(LTCTL1)               = 332,   /* size 1 */
  __UNDER__(LTCTL2)               = 333,   /* size 1 */
  __UNDER__(LTCTL3)               = 334,   /* size 1 */
  __UNDER__(LTSTAT0)              = 335,   /* size 1 */
  __UNDER__(LTSTAT1)              = 336,   /* size 1 */
  __UNDER__(LTSTAT2)              = 337,   /* size 1 */
  __UNDER__(LTSTAT3)              = 338,   /* size 1 */
  __UNDER__(LTSTATC0)             = 339,   /* size 1 */
  __UNDER__(LTSTATC1)             = 340,   /* size 1 */
  __UNDER__(LTSTATC2)             = 341,   /* size 1 */
  __UNDER__(LTSTATC3)             = 342,   /* size 1 */
  __UNDER__(LRCTL0)               = 343,   /* size 1 */
  __UNDER__(LRCTL1)               = 344,   /* size 1 */
  __UNDER__(LRCTL2)               = 345,   /* size 1 */
  __UNDER__(LRCTL3)               = 346,   /* size 1 */
  __UNDER__(LRSTAT0)              = 347,   /* size 1 */
  __UNDER__(LRSTAT1)              = 348,   /* size 1 */
  __UNDER__(LRSTAT2)              = 349,   /* size 1 */
  __UNDER__(LRSTAT3)              = 350,   /* size 1 */
  __UNDER__(LRSTATC0)             = 351,   /* size 1 */
  __UNDER__(LRSTATC1)             = 352,   /* size 1 */
  __UNDER__(LRSTATC2)             = 353,   /* size 1 */
  __UNDER__(LRSTATC3)             = 354,   /* size 1 */
  __UNDER__(ILATL)                = 255,   /* size 1 */
  __UNDER__(ILATH)                = 256,   /* size 1 */
  __UNDER__(ILATSTL)              = 257,   /* size 1 */
  __UNDER__(ILATSTH)              = 258,   /* size 1 */
  __UNDER__(ILATCLL)              = 259,   /* size 1 */
  __UNDER__(ILATCLH)              = 260,   /* size 1 */
  __UNDER__(IMASKL)               = 261,   /* size 1 */
  __UNDER__(IMASKH)               = 262,   /* size 1 */
  __UNDER__(INTCTL)               = 263,   /* size 1 */
  __UNDER__(PMASKL)               = 264,   /* size 1 */
  __UNDER__(PMASKH)               = 265,   /* size 1 */
  __UNDER__(TIMER0L)              = 266,   /* size 1 */
  __UNDER__(TIMER0H)              = 267,   /* size 1 */
  __UNDER__(TMRIN0L)              = 268,   /* size 1 */
  __UNDER__(TMRIN0H)              = 269,   /* size 1 */
  __UNDER__(TIMER1L)              = 270,   /* size 1 */
  __UNDER__(TIMER1H)              = 271,   /* size 1 */
  __UNDER__(TMRIN1L)              = 272,   /* size 1 */
  __UNDER__(TMRIN1H)              = 273,   /* size 1 */
  __UNDER__(IVKERNEL)             = 359,   /* size 1 */
  __UNDER__(IVTIMER0LP)           = 360,   /* size 1 */
  __UNDER__(IVTIMER1LP)           = 361,   /* size 1 */
  __UNDER__(IVLINK0)              = 362,   /* size 1 */
  __UNDER__(IVLINK1)              = 363,   /* size 1 */
  __UNDER__(IVLINK2)              = 364,   /* size 1 */
  __UNDER__(IVLINK3)              = 365,   /* size 1 */
  __UNDER__(IVDMA0)               = 366,   /* size 1 */
  __UNDER__(IVDMA1)               = 367,   /* size 1 */
  __UNDER__(IVDMA2)               = 368,   /* size 1 */
  __UNDER__(IVDMA3)               = 369,   /* size 1 */
  __UNDER__(IVDMA4)               = 370,   /* size 1 */
  __UNDER__(IVDMA5)               = 371,   /* size 1 */
  __UNDER__(IVDMA6)               = 372,   /* size 1 */
  __UNDER__(IVDMA7)               = 373,   /* size 1 */
  __UNDER__(IVDMA8)               = 374,   /* size 1 */
  __UNDER__(IVDMA9)               = 375,   /* size 1 */
  __UNDER__(IVDMA10)              = 376,   /* size 1 */
  __UNDER__(IVDMA11)              = 377,   /* size 1 */
  __UNDER__(IVDMA12)              = 378,   /* size 1 */
  __UNDER__(IVDMA13)              = 379,   /* size 1 */
  __UNDER__(IVIRQ0)               = 380,   /* size 1 */
  __UNDER__(IVIRQ1)               = 381,   /* size 1 */
  __UNDER__(IVIRQ2)               = 382,   /* size 1 */
  __UNDER__(IVIRQ3)               = 383,   /* size 1 */
  __UNDER__(VIRPT)                = 384,   /* size 1 */
  __UNDER__(IVBUSLK)              = 385,   /* size 1 */
  __UNDER__(IVTIMER0HP)           = 386,   /* size 1 */
  __UNDER__(IVTIMER1HP)           = 387,   /* size 1 */
  __UNDER__(IVHW)                 = 388,   /* size 1 */
  __UNDER__(IVSW)                 = 389,   /* size 1 */
  __UNDER__(FLAGREG)              = 308,   /* size 1 */
  __UNDER__(FLAGREGST)            = 310,   /* size 1 */
  __UNDER__(FLAGREGCL)            = 309,   /* size 1 */

  __END_OF_SYSREGS                = -1

};

#define __read_ccnt() \
   (__builtin_compose_64(__builtin_sysreg_read(__UNDER__(CCNT0)), \
                         __builtin_sysreg_read(__UNDER__(CCNT1))))

#endif /* __SYSREG_DEFINED */
